package pers.flowerinsnow.minecraft.forge.shiftability.manager.impl

import net.minecraftforge.common.config.Configuration
import net.minecraftforge.common.config.Property
import pers.flowerinsnow.minecraft.forge.shiftability.manager.ISAConfigManager
import java.io.File

class SAConfigManagerImpl(override val file: File) : ISAConfigManager {
    private val config : Configuration = Configuration(file)
    init {
        reload()

    }

    override val configInstance: Configuration
        get() = this.config

    override fun get(category: String, key: String, default: Boolean): Property {
        return config.get(category, key, default)
    }

    override fun get(category: String, key: String, default: BooleanArray): Property {
        return config.get(category, key, default)
    }

    override fun get(category: String, key: String, default: Double): Property {
        return config.get(category, key, default)
    }

    override fun get(category: String, key: String, default: DoubleArray): Property {
        return config.get(category, key, default)
    }

    override fun get(category: String, key: String, default: Int): Property {
        return config.get(category, key, default)
    }

    override fun get(category: String, key: String, default: IntArray): Property {
        return config.get(category, key, default)
    }

    override fun get(category: String, key: String, default: String): Property {
        return config.get(category, key, default)
    }

    override fun get(category: String, key: String, default: Array<String>): Property {
        return config.get(category, key, default)
    }

    override fun reload(): ISAConfigManager {
        config.load()
        ISAConfigManager.ConfigEntry.values().forEach { u -> u.get(config) }
        save()
        return this
    }

    override fun save() : ISAConfigManager {
        config.save()
        return this
    }
}